"""登录页面"""
from common.base import Base
from config import host_url
from selenium.webdriver.common.by import By


class ClassroomPage(Base):
    url = "/Main/index.html"

    # 页面元素定位
    add_course_locator = (By.XPATH, "//div[@class='ktcon1l fr']")  # 加入课程按钮
    add_course_window_verification_code_input_locator = (
        By.XPATH, "//div[@class='chuangjiankccon']/input")  # 请输入课程加课验证码 输入框
    add_course_window_add_locator = (By.XPATH, "//a[text()='加入']")  # 加入按钮
    add_course_window_cancel_locator = (By.XPATH, "//a[@class='btn btn-defalut']")  # 取消按钮

    more_locator = (By.CLASS_NAME, 'kdmore')  # 课程上的更多按钮

    quit_course_locator = (By.XPATH, "//a[text()='退课']")  # 退课按钮
    quit_course_window_pwd_locator = (
        By.XPATH, "//div[@class='deletekccon']/input[@type='password']")  # 退课弹出框的输入登录密码验证输入框
    quit_course_window_bt_cancel_locator = (By.XPATH, "//div[@class='deletebot cl']/ul/li/a[text()='取消']")  # 退课弹出框的取消按钮
    quit_course_window_bt_confirm_locator = (
        By.XPATH, "//div[@class='deletebot cl']/ul/li/a[text()='退课']")  # 退课弹出框的退课按钮

    class_locator = (By.CLASS_NAME, "jumptoclass")  # 进入班级的入口
    privateLetter_locator = (By.CLASS_NAME, "privateLetter")  # 私信

    def operate_more(self):
        # 操作课程的更多按钮
        self.click(self.more_locator)

    # 加入课程
    def add_course(self):
        # 操作加入课程
        self.click(self.add_course_locator)

    def add_course_window_input_verification_code(self, code):
        "加课弹出框，输入加课验证码"
        self.input(locator=self.add_course_window_verification_code_input_locator, data=code)

    def add_course_window_cancel(self):
        "加课弹出框，点击取消按钮"
        self.click(self.add_course_window_cancel_locator)

    def add_course_window_confrim(self):
        "加课弹出框，点击加入按钮"
        self.click(self.add_course_window_add_locator)

    # 退课
    def quit_course(self):
        # 操作退课
        self.operate_more()
        self.click(self.quit_course_locator)

    def quit_course_window_input_pwd(self, pwd):
        "退课弹出框，输入登录验证码"
        self.input(locator=self.quit_course_window_pwd_locator, data=pwd)

    def quit_course_window_cancel(self):
        "退课弹出框，点击取消按钮"
        self.click(self.quit_course_window_bt_cancel_locator)

    def quit_course_window_confrim(self):
        "退课弹出框，点击退课按钮"
        self.click(self.quit_course_window_bt_confirm_locator)

    # 页面跳转
    def jump_to_class(self):
        # 进入班级
        self.click(self.class_locator)

    def jump_to_private_letter(self):
        # 进入私信
        self.click(self.privateLetter_locator)
